// Thud - a dynamic object-oriented language
// Copyright (C) 2009,2010 David H. Hovemeyer <david.hovemeyer@gmail.com>

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

/*
 * Magic.h
 *
 *  Created on: Nov 30, 2009
 *      Author: dhovemey
 */

#ifndef MAGIC_H_
#define MAGIC_H_

/**
 * @file
 * @brief Magic constants used in bytecode classes/methods.
 */

#include <cstdint>

// classfile magic number and version constants

/** Magic number: first 4 bytes of classfile. */
const uint32_t CLASS_MAGIC = 0xe5e6798f;

/** Classfile major version. */
const uint16_t CLASS_MAJOR = 0;

/** Classfile minor version. */
const uint16_t CLASS_MINOR = 0;

// class flags

/** Class flag to indicate that the class is a module. */
const uint32_t CLASS_FLAG_MODULE = 1;

/** Class flag to indicate that the class has magic methods. */
const uint32_t CLASS_FLAG_MAGIC = 2;

// method flags

/** Method flag to mark a magic (as opposed to bytecode) method. */
const uint32_t METHOD_FLAG_MAGIC = 1;

// bytecode limits

/** Maximum number of constants that a class may have. */
const uint32_t CLASS_MAX_CONSTANTS = (1 << 16);

/** Maximum number of local variables that a method may have. */
const uint32_t METHOD_MAX_LOCALS = 128;

#endif /* MAGIC_H_ */
